package com.ht.system.api.factory;

import com.ht.common.core.domain.R;
import com.ht.system.api.RemoteInitDictService;
import com.ht.system.api.dto.DictDto;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * @author zmx
 * @version V1.0
 * @Title: RemoteBaseInfoFieldFallbackFactory.java
 * @date 2021年11月10日
 */
@Component
public class RemoteInitDictFallbackFactory implements FallbackFactory<RemoteInitDictService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteInitDictFallbackFactory.class);

    @Override
    public RemoteInitDictService create(Throwable throwable) {
        log.error("初始化系统字典调用失败:{}", throwable.getMessage());
        return new RemoteInitDictService() {
            @PostMapping("/dict/type/remoteAddDict")
            @Override
            public R<Boolean> initSysDict(DictDto dictDto, String source) {
                return R.fail("初始化系统字典失败:" + throwable.getMessage());
            }
        };
    }
}
